package com.bsoft.gol.hbs.bean.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * 文章状态枚举
 *
 * @author linyi
 * @date 2021/10/13 13:54
 */
public enum ArticleStatusEnum {

    EDITED(1),
    SUBMITTED(2),
    RELEASED(3);

    private int state;

    ArticleStatusEnum(int state) {
        this.state = state;
    }

    public static ArticleStatusEnum getByState(int state) {
        Optional<ArticleStatusEnum> first = Arrays.stream(ArticleStatusEnum.values())
                .filter(e -> e.getState() == state).findFirst();
        return first.orElse(null);
    }

    public int getState() {
        return state;
    }
}
